<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
 <head>
  <title>排班表</title>
  <t:base type="jquery,easyui,tools,DatePicker"></t:base>
  <script type="text/javascript">
	function toSave(){
		var data=$("#timeTable").serialize();
		$.ajax({
			url: "<%=path%>/tmblWorktimeController.do?doSaveTable",
			type:"post",
			dataType:"json",
			data:data,
			success: function(data){
				alert(data.msg);
				$("#save").hide();
			}
		});
	}
	
	
	var id=0;
	function selectAppUser(ids){
		$.dialog.setting.zIndex = getzIndex(true); 
		id=ids;
		$.dialog({content: 'url:tmblWorktimeParentController.do?goSelectAppUser', 
				zIndex: 2100, title: '用户列表', lock: true, width: '500px', 
				height: '600px', opacity: 0.4, 
		button: [
		   {name: '确定', callback:callbackDepartmentSelect, focus: true},
		   {name: '取消', callback: function (){}}
	   ]}).zindex();
	}
	
	function callbackDepartmentSelect(){
		
		 var iframe = this.iframe.contentWindow;
	    var rowsData = iframe.$('#selectAppUser').datagrid('getSelections');
   		 if (!rowsData || rowsData.length==0) {
	        tip('<t:mutiLang langKey="common.please.select.edit.item"/>');
	        return;
   		 }
	  
	    var cde = rowsData[0].empCde;
	    var name = rowsData[0].empName;
	    $("#cde"+id).val(cde);
	    $("#"+id).val(name);
	    $("#"+id).blur();
	}
  </script>
  <style type="text/css">
  	.tableA{
  	border-collapse:collapse;
  	
  	}
  	
  	input{
		width: 55px;
		height: 19px;
	}
	td{
		font-size:15px;
		margin-left: 10px;
		text-align: center;
		border: 1px solid black;
	}
	tr{
		
		height: 50px;
	}
  </style>
 </head>
<body>
	<form id="timeTable"  action="" >
	
		<table class="tableA" border="1" cellpadding ="5" cellspacing="10" style="width: 100%;height: 100%;">
			<tr>
			<td > <% for(int i=0;i<29;i++){ %>&nbsp;<%} %></td>	
				<c:forEach items="${daysList }" var="day">
				<td>${day}</td>
				</c:forEach>
			</tr>
			
			<%int i=0; %>
<c:forEach items="${wdataList }" var="wd">
<tr >
		<td style="width:20%;">${wd.workPlaceName }</td>
				<c:forEach items="${wd.dataList }" var="data">
				<td>
	            	
	                <input type="hidden" name="wtList[<%=i %>].workplace" value="${wd.workPlaceName }"/>
	                <input type="hidden" name="wtList[<%=i %>].workPlaceId" value="${wd.workPlaceId }"/>
	                 <input type="hidden" name="wtList[<%=i %>].parentId" value="${pId }"/>
	                 <input type="hidden" name="wtList[<%=i %>].workdate"  value="${data }"/>
	            	
	            	<input type="hidden" id="cde<%=i %>" name="wtList[<%=i %>].empcdoe" value=""/>
	            	<input type="text" id="<%=i %>" onclick="selectAppUser(<%=i %>)" name="wtList[<%=i %>].empname" style="height: 25px; font-size:16px;" value=""/>
	             </td>
	             <%i=i+1; %>
	             </c:forEach>
             
	
</tr>
</c:forEach>	
	
		</table>
	</form>
	<div style="margin-top: 6px;"><input id="save" type="button" style="width:70px;height: 30px; font-size: 17px;"  value="保存" onclick="toSave()"/></div>
</body>
</html>